package com.maoyu.cloud.user.repository;

import com.maoyu.cloud.mybatis.entity.PtUserEntity;
import com.maoyu.cloud.mybatis.entity.ZtreeEntity;
import com.maoyu.cloud.mybatis.flexigrid.PagingBean;
import com.maoyu.cloud.user.entity.SearchUserEntity;
import com.maoyu.cloud.user.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;

import java.util.List;

@Mapper
public interface UserInfoDao {
    List<PtUserEntity> queryUserInfoList(@Param("search") SearchUserEntity search);

    void modifyPassword(@Param("password") String newPassword, @Param("userUuid") String userUuid);

    PtUserEntity queryUserByUuid(@Param("userUuid") String userUuid,@Param("password") String oldPassword);

    /**
     * 获取分页用户列表
     * @param search
     * @param paging
     * @return
     */
    List<PtUserEntity> getUserInfolistByPage(@Param("search")SearchUserEntity search,@Param("paging") PagingBean paging);

    /**
     * 获取总数
     * @param search
     * @return
     */
    Integer getUserInfolistTotal(@Param("search")SearchUserEntity search);

    /**
     * 增加用户
     * @param userEntity
     */
    void addUser(@Param("entity") UserEntity userEntity);

    /**
     * 根据用户名查询用户数量
     * @param userName 用户名
     * @return 0 or 1
     */
    Integer queryUserCountByName(@Param("user_name") String userName);

    /**
     * 根据邮箱查询用户数量
     * @param email 邮箱
     * @return 0 or 1
     */
    Integer queryUserCountByEmial(@Param("email") String email);

    /**
     * 根据手机号查询用户数量
     * @param mobile 手机号
     * @return 0 or 1
     */
    Integer queryUserCountByMobile(@Param("mobile") String mobile);

    /**
     * 根据id查询用户信息
     * @param userUuid
     * @return
     */
    UserEntity queryUserInfoById(@Param("userUuid") String userUuid);

    void updateUserInfo(@Param("entity") UserEntity userEntity);

    Integer queryUserCountByNameNotId(@Param("user_name") String userName, @Param("user_uuid") String userUuid);

    Integer queryUserCountByEmialNotId(@Param("email") String email, @Param("user_uuid") String userUuid);

    Integer queryUserCountByMobileNotId(@Param("mobile") String mobile, @Param("user_uuid") String userUuid);

    void deleteUserInfoByIds(@Param("userUuidsArray") String[] userUuidsArray);

    List<ZtreeEntity> queryRoleZtreeAll();

    void deleteRoleByUser(@Param("userUuid") String userUuid);

    void insertRoleByUser(@Param("userUuid") String userUuid, @Param("roleUuid") String rolesArray);

    List<String> queryRoleZtreeListByUserId(@Param("userUuid") String userUuid);

    /**
     * 根据id重置密码
     * @param userUuids
     * @param password
     */
    void resetPasswordByIds(@Param("userUuids") String[] userUuids, @Param("password") String password);

    void save(PtUserEntity user);
}